package list_map.fail_fast;

import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Iterator;

/**
 * @program: javase
 * @description: 快速失败
 * @author: luolidong
 * @create: 2021-06-30 19:32
 * @version: 1.0
 */
public class HashTableTest {
    public static void main(String[] args) {
        Hashtable<String, String> hashtable = new Hashtable<>();
        hashtable.put("1", "1");
        hashtable.put("2", "2");
        hashtable.put("3", "3");
        hashtable.put("4", "4");

        Iterator<String> iterator = hashtable.keySet().iterator();
        while (iterator.hasNext()) {
            System.out.println(iterator.next());
            iterator.remove();
        }
//        for (String s : hashtable.values()) {
//            hashtable.remove("3");
//            System.out.println(s);
//        }
//        Enumeration<String> elements = hashtable.elements();
//        while (elements.hasMoreElements()) {
//            System.out.println(elements.nextElement());
//            hashtable.remove("3");
//        }

    }
}
